<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * Link dialog window.
-->
<html>
<head>
	<title>Special Tag Properties</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex, nofollow" />
	<script type="text/javascript">

var oEditor		= window.parent.InnerDialogLoaded() ;
var FCK			= oEditor.FCK ;
var FCKLang		= oEditor.FCKLang ;
var FCKConfig	= oEditor.FCKConfig ;
var FCKRegexLib	= oEditor.FCKRegexLib ;
var FCKTools	= oEditor.FCKTools ;

document.write( '<script src="' + FCKConfig.BasePath + 'dialog/common/fck_dialog_common.js" type="text/javascript"><\/script>' ) ;

	</script>
	<script type="text/javascript">

// Get the selected flash embed (if available).
var oFakeImage = FCK.Selection.GetSelectedElement() ;
var oTemplateSpan ;
var sFakeClass = 'FCK__MWSpecial';
var sSelectedTag = "";

if ( oFakeImage )
{
	if ( oFakeImage.tagName == 'IMG' )
	{
		if ( oFakeImage.getAttribute('_fck_mw_special') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWSpecial';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_html') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWHtml';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_nowiki') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWNowiki';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_noinclude') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWNoinclude';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_gallery') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWGallery';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_onlyinclude') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWOnlyinclude';
		}
		else if ( oFakeImage.getAttribute('_fck_mw_includeonly') )
		{
			oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
			sFakeClass = 'FCK__MWIncludeonly';
		}
		else
			oFakeImage = null ;
	}
	else
		oFakeImage = null ;
}

window.onload = function()
{
	// Translate the dialog box texts.
	oEditor.FCKLanguageManager.TranslatePage(document) ;

	// Load the selected link information (if any).
	LoadSelection() ;
	LoadDocumentation();

	// Activate the "OK" button.
	window.parent.SetOkButton( true ) ;
	window.parent.SetAutoSize( true ) ;
	GetE('xTemplateRaw').focus();
}

function LoadSearchResults( result )
{
	var results = result.responseText.Trim().split( '\n' ) ;
	var select = GetE( 'xSelectTag' ) ;

	if ( results.length > 0 && !( results.length == 1 && results[0].length == 0 ) )
	{
		for ( var i = 0 ; i < results.length ; i++ )
			FCKTools.AddSelectOption( select, results[i], results[i] ) ;
	}

	if ( sSelectedTag ) {
		select.value = sSelectedTag ;
	}
}


function LoadSelection()
{
	// Make an Ajax search for the pages.
	var empty = '';
	oEditor.window.parent.sajax_request_type = 'GET' ;
	oEditor.window.parent.sajax_do_call( 'wfSajaxSearchSpecialTagFCKeditor',[empty], LoadSearchResults ) ;

	if ( !oTemplateSpan ) return ;

	GetE('xTemplateRaw').value = FCKTools.HTMLDecode(oTemplateSpan.innerHTML).replace(/fckLR/g,'\r\n' ).replace( /&quot;/g, '"' ) ;
	var tagName = oTemplateSpan.getAttribute('_fck_mw_tagname').toLowerCase();

	sSelectedTag = tagName ;
	GetE('xSelectTag').value = tagName;
}

function LoadDocumentation()
{
	var tagName = GetE('xSelectTag').value;
	if (tagName == 'dpl')
	{
		if (!FCKLang.DplHelp) FCKLang.DplHelp = 'DPL stands for Dynamic Page List, and allows to generate a formatted list of pages based on selection criteria. See %link for details';
		GetE('xDefinition').innerHTML = FCKLang.DplHelp.replace( /%link/g, '<a href="#" onclick="javascript:window.open(\'http://semeb.com/dpldemo/index.php?title=Dynamic_Page_List\')">manual</a>' ) ;
	}
	if (tagName == 'inputbox')
	{
		if (!FCKLang.inputboxHelp) FCKLang.inputboxHelp = 'Inputbox allows to create a form for users to create new pages. The new pages edit box can be pre-loaded with any template. See %link for details';
		GetE('xDefinition').innerHTML = FCKLang.inputboxHelp.replace( /%link/g, '<a href="#" onclick="javascript:window.open(\'http://meta.wikimedia.org/wiki/Help:Inputbox\')">manual</a>' ) ;
	}
}

//#### The OK button was hit.
function Ok()
{
	if ( !oTemplateSpan )
	{
		oTemplateSpan = FCK.EditorDocument.createElement( 'SPAN' ) ;
		oTemplateSpan.className = 'fck_mw_special' ;
		SetAttribute( oTemplateSpan, '_fck_mw_customtag', 'true' ) ;
	}

	var templateData = FCKTools.HTMLEncode(GetE('xTemplateRaw').value.Trim().replace(/(\r\n|\n)/g, 'fckLR' )).replace( /"/g, '&quot;' ) ;

	oTemplateSpan.innerHTML = templateData ;
	SetAttribute( oTemplateSpan, '_fck_mw_tagname', GetE('xSelectTag').value ) ;

	switch (GetE('xSelectTag').value)
	{
		case 'noinclude':
		sFakeClass = 'FCK__MWNoinclude';
		break;
		case 'gallery':
		sFakeClass = 'FCK__MWGallery';
		break;
		case 'nowiki':
		sFakeClass = 'FCK__MWNowiki';
		break;
		case 'includeonly':
		sFakeClass = 'FCK__MWIncludeonly';
		break;
		case 'html':
		sFakeClass = 'FCK__MWHtml';
		break;
		case 'onlyinclude':
		sFakeClass = 'FCK__MWOnlyinclude';
		break;
		default:
		sFakeClass = 'FCK__MWSpecial';
		break;
	}

	if ( !oFakeImage )
	{
		oFakeImage	= oEditor.FCKDocumentProcessor_CreateFakeImage( sFakeClass, oTemplateSpan ) ;
		oFakeImage.setAttribute( '_fck_mw_special', 'true', 0 ) ;
		oFakeImage	= FCK.InsertElement( oFakeImage ) ;
	}
	else
		oFakeImage.className = sFakeClass ;

	return true ;
}

	</script>
</head>
<body style="overflow: hidden">
	<div id="divInfo">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
			<tr>
				<td>
					<span fcklang="wikiSpTag">Current Special Tag</span>:
					<select id="xSelectTag" onchange="LoadDocumentation()">
					</select><br>
					<i><span id="xDefinition"></span></i>
				</td>
			</tr>
			<tr>
				<td>
					<hr>
					<span fcklang="wikiSpParam">Special tag parameters</span>:
			</tr>
			<tr>
				<td height="100%">
					<textarea id="xTemplateRaw" style="width: 100%; height: 100%; font-family: Monospace"
						cols="50" rows="10" wrap="off"></textarea>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>
